package lab02.test23;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws ParseException {
        //输入生日信息
        String Time;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的生日，格式如：xxxx-xx-xx");

        Time=scanner.nextLine();
        Calendar time = Calendar.getInstance();
        String year = Time.substring(0, 4);
        String month = Time.substring(6, 7);
        String day = Time.substring(9,10);
        time.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
        System.out.println("你的生日是星期几:");

        int  week= time.get(Calendar.DAY_OF_WEEK);
        System.out.println("DAY_OF_WEEK"+"="+week);
        switch (week) {
            case 1:
                System.out.println("星期天");
                break;
            case 2:
                System.out.println("星期一");
                break;
            case 3:
                System.out.println("星期二");
                break;
            case 4:
                System.out.println("星期三");
                break;
            case 5:
                System.out.println("星期四");
                break;
            case 6:
                System.out.println("星期五");
                break;
            default:
                System.out.println("星期六");
                break;
            }
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-mm-dd");

            Calendar calendar=Calendar.getInstance();

            calendar.setTime(sdf.parse(Time));
            long time1=calendar.getTimeInMillis();

            calendar.setTime(sdf.parse("2017-11-02"));
            long time2=calendar.getTimeInMillis();
            System.out.println(" 距离生日还差多少天 ："+(time1-time2)/(24*3600*1000));
    }
}
